package com.china08.yxyapi.repository.db;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.china08.yxyapi.entity.db.res.YxyResBookContentsKnoledges;

public interface YxyResBookContentsKnoledgesRepository extends JpaRepository<YxyResBookContentsKnoledges, String> {

    List<YxyResBookContentsKnoledges> findByBookContentId(String bookcontentId);

    List<YxyResBookContentsKnoledges> findByBookContentIdIn(List<String> bookcontent);

    @Query(value = "select knowledgeId  from YxyResBookContentsKnoledges where bookContentId in ?1")
    List<Integer> findKonwId(List<String> bookContent);

    @Query(value = "select knowledgeId  from YxyResBookContentsKnoledges where bookContentId = ?1")
    List<Integer> findKonwIdBy(String bookContent);

    @Query(nativeQuery = true, value = "select distinct kc.knowledge_id from yxy_res.yxy_res_book_contents_knoledges kc where kc.book_content_id in (?1) ")
    List<Object> getKnowledge(List<String> bookContentId);

    @Query(value = "select bookContentId from YxyResBookContentsKnoledges where knowledgeId in ?1 group by bookContentId")
    List<String> getBookcontentByKnowIdIn(List<Integer> know);

}
